package process;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

import android.os.Message;

public class TCPClient {
	private Socket  socket ;
	private OutputStream output ;
	public String KetNoi(String Chuoi)
	{
		String kn = "";
		String address = "192.168.2.102";
		int port = 8080;
		
		try {
			socket = new Socket(address, port);
			output = socket.getOutputStream();
			BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(output));
			BW.write(Chuoi);
			BW.flush();
			output.close();
			socket.close();
			kn = "Thành Công";
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			kn = "Kết nối không thành công";
		} catch (IOException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			kn = "Kết nối không thành công";
		}
		return kn;
	}
}
